<?php
declare (strict_types = 1);
namespace app\course\model\record;

use app\common\model\BaseModel;

/**
 * 用户学习记录模型
 */
class LearnDailyRecord extends BaseModel
{
    /**
     * 表名
     * @var string
     */
    protected $name = 'user_learn_daily_record';

    /**
     * 设置自动写入时间
     * @var boolean
     */
    protected $autoWriteTimestamp = true;

    /**
     * 定义字段类型
     * @var array
     */
    protected $type = [
        'id'          => 'integer',
        'update_time' => 'integer',
    ];

    public function scopeExistRecord($query, $mid)
    {
        $mid = $mid?:request()->mid;
        $query->where('user_id', $mid);
    }
    
}
